<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>网页文字转语音</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<script type="text/javascript">

</script>

<style type="text/css">
</style>
</head>
    <body>
    文字：<input type="text" value="你好啊！请罗易到骨科一诊室就诊" id="inpu">
    <button onclick="sayTTS()">发声</button>
    </body>
    <script>
    function sayTTS()
    {
        var content = document.getElementById('inpu');
        console.log(content.value);
        const synth = window.speechSynthesis;
        const msg = new SpeechSynthesisUtterance();
        msg.text = content.value;     // 文字内容
        msg.lang = "zh-CN";  // 使用的语言:中文
        msg.volume = 0.8;      // 声音音量：0-1
        msg.rate = 1.5;        // 语速：0-10
        msg.pitch = 0.8;       // 音高：0-1
        synth.speak(msg);    // 播放
    }
    </script>
</html>